#! /usr/bin/env python
# -*- coding: utf-8 -*-


import jenkins
import os
template_xml="build_demo.xml"
svn_url = 'svn://192.168.5.181/BI数据展示/项目代码/bi-back/trunk'
jenkins_root = '/data/jenkins/'

job_build_name = 'test_demo4_build'

dir_name = jenkins_root+'jobs/'+job_build_name
#if not os.path.exists(dir_name):
#    os.makedirs(dir_name)

with open(template_xml) as f:
    profile = f.read()

#print(profile)

xml=profile.replace("svn_url", svn_url)

#xml_name = 'config.xml'
#with open(xml_name,'w') as f:
#    f.write(JOB_CONFIG)

#config_filename = '/root/config.xml'

#与网页版Jenkins登录的账号、密码一致
server = jenkins.Jenkins('http://192.168.18.196:8080/', username='admin', password='Wgmf@1234!')
xml = xml.strip()
server.create_job(job_build_name,xml)

